<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0
    }

    /* 浅色主题 */
    .light .content {
      width: 100vw;
      height: 100vh;
      background-color: white;
      color: #333333;
      transition: all 0.3s;
    }

    /* 深色主题 */
    .dark .content {
      width: 100vw;
      height: 100vh;
      background-color: #333333;
      color: white;
      transition: all 0.3s;
    }

    button {
      position: fixed;
      top: 100px;
      right: 100px;
    }
  </style>
</head>

<body class="light">
  <div class="content">我是一个 div</div>
  <button onclick="change()">点我切换模式</button>
</body>

<script>
  // 切换模式
  function change() {
    document.body.className = document.body.className === 'light' ? 'dark' : 'light'
  }
</script>

</html>